using System;
using System.Collections.Generic;
using System.Text;
using CommonTypes;

namespace MVCFramework.Models.Filters
{
    public class CompositeFilter:List<IFilter>,IFilter
    {
        Id<IFilter> id;

        public Id<IFilter> Id
        {
            get { return id; }
            set { id = value; }
        }
        #region IFilter Members

        public bool CheckAdd(object element)
        {
            bool control = true ;
            foreach (IFilter filter in this)
                control = control && filter.CheckAdd(element);
            return control;   
        }

        public bool CheckGet(object element)
        {
            bool control = true;
            foreach (IFilter filter in this)
                control = control && filter.CheckGet(element);
            return control;   
        }

        public bool CheckRemove(object element)
        {
            bool control = true;
            foreach (IFilter filter in this)
                control = control && filter.CheckRemove(element);
            return control;   
        }

        public bool CheckModify(object element, Vector v)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public IModel Model
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public bool IsActivated
        {
            get
            {
                bool control = true;
                foreach (IFilter filter in this)
                {
                    if(filter != null)
                    control = control && filter.IsActivated;
                }
                return control;   
            }
            set
            {
                foreach (IFilter filter in this)
                    filter.IsActivated = value;
            }
        }

        #endregion
    }
}
